﻿using DG.Tweening;
using System;
using UnityEngine;
using UnityEngine.UI;

public class ImageItem : MonoBehaviour
{
    private Image image;

    // Start is called before the first frame update
    void Start()
    {
        image = GetComponent<Image>();
    }


    public void ChangeScale(float endScale,float timer, Action callback)
    {
        transform.DOKill();
        transform.DOScale(Vector3.one * endScale, timer).OnComplete(() => { callback?.Invoke(); });
    }

    public void ChangeImage(int id)
    {
        string path = string.Format("Image/{0}", id);
        Sprite sprite = Resources.Load<Sprite>(path);
        if (image == null)
            image = GetComponent<Image>();
        image.sprite = sprite;
    }
}
